#include <iostream>

#include "cyber_rate.h"

using apollo::cyber::Rate;
using apollo::cyber::Time;

int64_t g_int = 0;

// 模拟耗时任务
void run_cpu() {
  for (int i = 0; i < 20 * 1024 * 1024; i++) {
    g_int += i * i;
  }
}

int main(int argc, char* argv[]) {
  Rate r(50.0);  // 50 Hz

  while (true) {
    std::cout << apollo::cyber::Time::Now() << "  " << r.CycleTime() << std::endl;
    run_cpu();
    r.Sleep();
  }
  return 0;
}
